package clientRMI;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

import serverRMI.IPilha;

public class Cliente {

	/**
	 * @param args
	 * @throws NotBoundException 
	 * @throws RemoteException 
	 * @throws MalformedURLException 
	 */
	public static void main(String[] args) throws MalformedURLException, RemoteException, NotBoundException {
		String host = "127.0.0.1";
		String component = "pilha"; // Nome no rebind do Obj remoto
		
		Object ob = Naming.lookup("rmi://" + host + "/" + component);
		
		IPilha pilha = (IPilha) ob;
		
		while (true){
			pilha.push(5);
			System.out.println(pilha.pop());
		}
	}
}
